/*
  Copyright 2002-2003 The University of Texas at Austin
  
	Authors: Anthony Thane <thanea@ices.utexas.edu>
			 Vinay Siddavanahalli <skvinay@cs.utexas.edu>
	Advisor: Chandrajit Bajaj <bajaj@cs.utexas.edu>

  This file is part of Volume Rover.

  Volume Rover is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  Volume Rover is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with iotree; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef ALPHAMAP_H
#define ALPHAMAP_H

#include <QList>
#include <QTextStream>

namespace PBVP {
	/// <summary>
	/// 
	/// </summary>
	class AlphaMapNode
	{
	public:
		/// <summary>
		/// 
		/// </summary>
		/// <param name="pos"></param>
		/// <param name="_alpha"></param>
		AlphaMapNode(double pos, double _alpha)
			: position(pos), alpha(_alpha) {}
		/// <summary>
		/// 
		/// </summary>
		virtual ~AlphaMapNode() {}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="node1"></param>
		/// <param name="node2"></param>
		/// <returns>bool</returns>
		friend bool operator < (const AlphaMapNode& node1, const AlphaMapNode& node2) {
			if (node1.position < node2.position) return true;
			return false;
		}
		/// <summary>
		/// 
		/// </summary>
		double alpha;
		/// <summary>
		/// 
		/// </summary>
		double position;
	};
	/// <summary>
	/// 
	/// </summary>
	class AlphaMap
	{
	public:
		/// <summary>
		/// 
		/// </summary>
		AlphaMap();
		/// <summary>
		/// 
		/// </summary>
		/// <param name="copy"></param>
		AlphaMap(const AlphaMap& copy);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="copy"></param>
		/// <returns>AlphaMap&</returns>
		AlphaMap operator=(const AlphaMap& copy);
		/// <summary>
		/// 
		/// </summary>
		virtual ~AlphaMap() {}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <param name="fAlpha"></param>
		void ChangeAlpha(int index, double fAlpha);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetAlpha(int index) const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetPosition(int index) const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="fPosition"></param>
		/// <returns>double</returns>
		double GetAlpha(double fPosition) const;
		/// <summary>
		/// 
		/// </summary>
		/// <returns>int</returns>
		int size() const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <param name="fPosition"></param>
		void MoveNode(int index, double fPosition);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="pos"></param>
		/// <param name="alpha"></param>
		void AddNode(double pos, double alpha);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="pos"></param>
		void AddNode(double pos);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		void DeleteNode(int index);

		/// <summary>
		/// 
		/// </summary>
		/// <param name="stream"></param>
		void saveMap( QTextStream& stream );
		/// <summary>
		/// 
		/// </summary>
		/// <param name="stream"></param>
		void loadMap( QTextStream& stream );
		/// <summary>
		/// 
		/// </summary>
		void removeSandwichedNodes();

	protected:
		/// <summary>
		/// 
		/// </summary>
		QList<AlphaMapNode> m_AlphaNodes;
	};
}
#endif
